package i7bac.scale;

import i7bac.container.ContainerGraph;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class Scale extends JPanel {

	// Current and maximum levels
	public int currentWeight, maxWeight;

	public Scale(int currentWeight, int maxWeight, Font font) {
		super(new BorderLayout(), true);
		this.setFont(font);
		this.setBorder(BorderFactory.createCompoundBorder(
			BorderFactory.createEmptyBorder(1,3,0,3),
			BorderFactory.createCompoundBorder(
				BorderFactory.createTitledBorder(BorderFactory.createLineBorder(new Color(90,130,191), 1, false), "Scale", 0, 0, font),
				BorderFactory.createEmptyBorder(0,5,5,5)
			)
		));
		this.setPreferredSize(new Dimension(110,200));
		this.currentWeight = currentWeight;
		this.maxWeight = maxWeight;
		
		// Scale Graph
		JPanel containerPanel = new JPanel(new BorderLayout(), true);
		containerPanel.setBorder(BorderFactory.createCompoundBorder(
				BorderFactory.createEmptyBorder(0,0,5,0),
				BorderFactory.createLoweredBevelBorder()
		));
		containerPanel.add(new ContainerGraph(this.currentWeight, this.maxWeight, Color.white, Color.green));
		this.add(containerPanel, BorderLayout.CENTER);
		
		// Calibrate Button
		JButton calibrateButton = new JButton("Calibrate");
		calibrateButton.setFont(font);
		calibrateButton.setFocusable(false);
		this.add(calibrateButton, BorderLayout.SOUTH);
	}

}
